Skip to content

feat: CalendarCache - filter generic calendars from subscription batch#7

Open
tomerqodo wants to merge 2 commits intoqodo_full_base_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7from
qodo_full_head_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7
Open

feat: CalendarCache - filter generic calendars from subscription batch#7
tomerqodo wants to merge 2 commits intoqodo_full_base_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7from
qodo_full_head_feat_calendarcache_-_filter_generic_calendars_from_subscription_batch_pr7

Conversation

@tomerqodo
Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#7

devin-ai-integration Bot and others added 2 commits January 25, 2026 12:02
Add filtering to SelectedCalendarRepository.findNextSubscriptionBatch to
exclude generic calendars (holidays, contacts, shared, imported, resources)
based on their externalId suffixes.

Changes:
- Add GENERIC_CALENDAR_SUFFIXES constant mapping providers to their
  generic calendar suffixes in AdaptersFactory
- Add getGenericCalendarSuffixes method to AdapterFactory interface
- Update findNextSubscriptionBatch to accept and use genericCalendarSuffixes
  parameter to filter out calendars with matching externalId suffixes
- Update CalendarSubscriptionService.checkForNewSubscriptions to pass
  generic calendar suffixes from the adapter factory
- Update tests to cover the new filtering logic

Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
@qodo-code-review
Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0)

Grey Divider


Action required

1. Repository filename/class mismatch 📘 Rule violation ✓ Correctness
Description
• The repository file is named SelectedCalendarRepository.ts but now exports
  PrismaSelectedCalendarRepository, violating the required Prisma<Entity>Repository filename/class
  convention.
• This reduces consistency/discoverability and can confuse imports and code search for the canonical
  repository implementation.
Code

packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[5]

+export class PrismaSelectedCalendarRepository implements ISelectedCalendarRepository {
Evidence
Compliance ID 7 requires repository filenames to follow Prisma<Entity>Repository.ts and match the
exported class name. The updated code exports PrismaSelectedCalendarRepository from a file still
named SelectedCalendarRepository.ts, which is a filename/class mismatch.

AGENTS.md
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[5-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PrismaSelectedCalendarRepository` is exported from `SelectedCalendarRepository.ts`, but repositories must follow the `Prisma&lt;Entity&gt;Repository.ts` naming convention with filename matching the exported class name.

## Issue Context
This violates the repository naming convention and can reduce discoverability and consistency across the codebase.

## Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Integrations optional mismatch 🐞 Bug ⛯ Reliability
Description
ISelectedCalendarRepository.findNextSubscriptionBatch declares integrations as optional, but
  the Prisma implementation requires it and uses it unguarded.
• If any caller omits integrations (allowed by the interface), Prisma will receive in: undefined
  and likely throw at runtime.
• This is also a contract mismatch between interface and implementation that invites future bugs.
Code

packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[R19-30]

    take,
    teamIds,
    integrations,
+    genericCalendarSuffixes,
  }: {
    take: number;
    teamIds: number[];
    integrations: string[];
+    genericCalendarSuffixes?: string[];
  }) {
    return this.prismaClient.selectedCalendar.findMany({
      where: {
Evidence
The interface explicitly allows integrations to be omitted, but the implementation both types it
as required and passes it directly into Prisma's in filter without defaulting/guarding against
undefined.

packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts[26-36]
packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[18-33]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`integrations` is optional in `ISelectedCalendarRepository.findNextSubscriptionBatch`, but the Prisma implementation requires it and uses it directly in `integration: { in: integrations }`. If a caller omits `integrations` (which the interface allows), this can cause a Prisma validation/runtime error.

### Issue Context
This PR adds another optional filter (`genericCalendarSuffixes`) and handles it defensively, making the lack of defensive handling for `integrations` more inconsistent and risky.

### Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts[26-36]
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[18-33]

### Suggested fix options
- Option A: Make `integrations` required in the interface (and update any callers/tests accordingly).
- Option B (more flexible): Keep it optional and update implementation:
 - Use `integration: integrations?.length ? { in: integrations } : undefined` (or conditionally spread the filter) so Prisma doesn&#x27;t receive `in: undefined`.
 - Decide expected behavior when `integrations` is omitted (e.g., return all integrations vs. return none).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



ⓘ The new review experience is currently in Beta. Learn more

Qodo Logo

import type { Prisma } from "@calcom/prisma/client";

export class SelectedCalendarRepository implements ISelectedCalendarRepository {
export class PrismaSelectedCalendarRepository implements ISelectedCalendarRepository {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Repository filename/class mismatch 📘 Rule violation ✓ Correctness

• The repository file is named SelectedCalendarRepository.ts but now exports
  PrismaSelectedCalendarRepository, violating the required Prisma<Entity>Repository filename/class
  convention.
• This reduces consistency/discoverability and can confuse imports and code search for the canonical
  repository implementation.
Agent prompt
## Issue description
`PrismaSelectedCalendarRepository` is exported from `SelectedCalendarRepository.ts`, but repositories must follow the `Prisma<Entity>Repository.ts` naming convention with filename matching the exported class name.

## Issue Context
This violates the repository naming convention and can reduce discoverability and consistency across the codebase.

## Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[1-6]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines 19 to 30
take,
teamIds,
integrations,
genericCalendarSuffixes,
}: {
take: number;
teamIds: number[];
integrations: string[];
genericCalendarSuffixes?: string[];
}) {
return this.prismaClient.selectedCalendar.findMany({
where: {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

2. Integrations optional mismatch 🐞 Bug ⛯ Reliability

ISelectedCalendarRepository.findNextSubscriptionBatch declares integrations as optional, but
  the Prisma implementation requires it and uses it unguarded.
• If any caller omits integrations (allowed by the interface), Prisma will receive in: undefined
  and likely throw at runtime.
• This is also a contract mismatch between interface and implementation that invites future bugs.
Agent prompt
### Issue description
`integrations` is optional in `ISelectedCalendarRepository.findNextSubscriptionBatch`, but the Prisma implementation requires it and uses it directly in `integration: { in: integrations }`. If a caller omits `integrations` (which the interface allows), this can cause a Prisma validation/runtime error.

### Issue Context
This PR adds another optional filter (`genericCalendarSuffixes`) and handles it defensively, making the lack of defensive handling for `integrations` more inconsistent and risky.

### Fix Focus Areas
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.interface.ts[26-36]
- packages/features/selectedCalendar/repositories/SelectedCalendarRepository.ts[18-33]

### Suggested fix options
- Option A: Make `integrations` required in the interface (and update any callers/tests accordingly).
- Option B (more flexible): Keep it optional and update implementation:
  - Use `integration: integrations?.length ? { in: integrations } : undefined` (or conditionally spread the filter) so Prisma doesn't receive `in: undefined`.
  - Decide expected behavior when `integrations` is omitted (e.g., return all integrations vs. return none).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant